package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.saas.domain.dao.SmsTemplateDao;
import com.xbongbong.saas.domain.entity.SmsTemplateEntity;
import com.xbongbong.saas.model.SmsTemplateModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @description:
 * @Author: hongxiao
 * @date: 2019-01-12 17:37
 */
@Service("SmsTemplateModel")
public class SmsTemplateModelImpl implements SmsTemplateModel {

    @Resource
    private SmsTemplateDao smsTemplateDao;

    @Override
    public Integer insert(SmsTemplateEntity entity){
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);

        return smsTemplateDao.insert(entity);
    }

    @Override
    public Integer update(SmsTemplateEntity entity){
        entity.setUpdateTime((long)DateUtil.getInt());

        return smsTemplateDao.update(entity);
    }

    @Override
    public Integer save(SmsTemplateEntity entity){

        if(entity.getId() == null || entity.getId().equals(0L)) {
            return smsTemplateDao.insert(entity);
        }
        return smsTemplateDao.update(entity);
    }

    @Override
    public Integer deleteByKey( Long key, String corpid){
        return smsTemplateDao.deleteByKey(key, corpid);
    }

    @Override
    public SmsTemplateEntity getByKey(Long key, String corpid){
        return smsTemplateDao.getByKey(key, corpid);
    }

    @Override
    public List<SmsTemplateEntity> findEntitys(Map<String ,Object>  param){
        return smsTemplateDao.findEntitys(param);
    }
    @Override
    public Integer getEntitysCount(Map<String ,Object> param){
        return smsTemplateDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

}
